package comtwo;

import java.util.LinkedList;
import java.util.List;

public class Demo2 {
    public static void main(String[] args) {
        LinkedList list = new LinkedList();

        //增，删，改，查
       /* list.add(5);
        list.add(2);
        list.add(3);
        list.set(0,5);*/
        list.add(2);
        list.addFirst(5);
        list.addLast(10);
        //查
        list.get(2);
        //list.get(0);
        System.out.println(list.getFirst());
        System.out.println(list.getLast());
        ;
        /*for (int i=0;i<list.size();i++){
            list.get(i);
        }*/
        for (Object object:list) {
            System.out.println(object.toString());
        }
        //删
        list.remove(0);
        list.removeFirst();
        list.removeLast();
        System.out.println(list.get(0).toString());

        //修
        System.out.println(list.set(0,2));
        System.out.println(list.get(0).toString());
        System.out.println(list.get(1).toString());
    }
}
